﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using SQLHelper;
public partial class admin_NewsAdmin_Search : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["search"] != "")
        {
            bind();
        }
    }
    protected void Search(object sender, EventArgs e)
    {
        string str = TextBox1.Text.ToString().Trim();
        if (str != "")
        {
            Response.Redirect("~/admin/NewsAdmin/Search.aspx?search=" + str);
        }
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        bind();
    }
    void bind()
    {
        int UserID = Master.UserID;
        string sql = "select * from news where title like '%" + Convert.ToString(Request["search"]) + "%'";
        DataSet res = DB.GetDataWithQuerySecond(sql, "news");
        GridView1.DataSource = res;
        GridView1.DataKeyNames = new string[] { "id" };
        GridView1.DataBind();
        DB.ColseSqlCon();
    }
}